package com.loy.controller;

import com.loy.entity.HelloProto;
import com.loy.entity.HelloServiceGrpc;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    /**
     * 1. 注入
     */
    @GrpcClient("grpc-server")
    private HelloServiceGrpc.HelloServiceBlockingStub blockingStub;

    @RequestMapping("/test1")
    public String test(String name){
        System.out.println("name = " + name);
        HelloProto.HelloResponse response = blockingStub.hello(HelloProto.HelloRequest.newBuilder().setName(name).build());
        return response.getResult();
    }
}
